<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>操作表单</title>
</head>
<body>

<form action="" onsubmit="return commit()">
    <p><label for="username">用户名: </label><input type="text" id="username" value="haha" name="username"></p>
    <p><label for="password">密码: </label><input type="password" id="password" name="password"></p>
    <p>性别:
        <input type="radio" value="man" name="sex" checked id="radio_man"><label for="radio_man">男</label>
        <input type="radio" value="women" name="sex" id="radio_women"><label for="radio_women">女</label>
    </p>
    <p><input type="submit" value="提交"></p>
</form>

<script>
    let username = document.getElementById("username");
    let password = document.getElementById("password");
    let radio_man = document.getElementById("radio_man");
    console.log(username.value);
    console.log(radio_man.checked);
    function commit() {
        console.log(username.value);
        console.log(password.value);
        // true: 可以提交 false: 阻止提交
        return false
    }
</script>

</body>
</html>